<?php
define ( 'DWZ_MSG_OK', 200 );
define ( 'DWZ_MSG_ERROR', 300 );
define ( 'DWZ_MSG_TIMEOUT', 301 );

class Dwz {
	public function getPost() {
		$aPost = Base::$oBase->Http_getPost ();
		foreach ( $aPost as $sKey => $sValue ) {
			if (($i = strrpos ( $sKey, '.' )) > 0) {
				$i ++;
				if (preg_match ( '/\.items\[(\d+?)\]\./', $sKey, $aMatch )) {
					$aInfo ['items'] [$aMatch [1]] [substr ( $sKey, $i )] = $sValue;
				} else {
					$aInfo [substr ( $sKey, $i )] = $sValue;
				}
			}
		}
		return $aInfo;
	}
	
	public function returnMessage($iCode, $sMessage, $sNavId = null, $sCallback = null, $sUrl = null) {
		$aArrary = array ();
		$aArrary ['statusCode'] = $iCode;
		$aArrary ['message'] = $sMessage;
		$aArrary ['navTabId'] = $sNavId;
		$aArrary ['callbackType'] = $sCallback == 'close' ? 'closeCurrent' : $sCallback;
		$aArrary ['forwardUrl'] = $sUrl;
		if ($sUrl) {
			$aArrary ['callbackType'] = 'forward';
		}
		exit ( json_encode ( $aArrary ) );
	}
}